{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f0fdabdb-7a52-4949-9307-4479fb285020",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n",
      "{'sca': '91ae832e', 'cna': 'aaKIIaRAjG0CAXxZAsJ/KgXj', 'tbsa': '7705bbbfc47c662c6fae7c81_1761719482_4', 'atpsida': '6d6f2d764b7a2565938012b1_1761719482_4'}\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "f=open(r'C:\\\\Users\\\\Administrator\\\\Desktop\\\\爬虫\\\\taobao-hk.txt') #打开所保存的cookies内容文件\n",
    "cookies={}                        #初始化cookies字典变量\n",
    "for line in f.read().split(';'):   #按照字符：进行划分读取。其设置为1就会把字符串拆分成2份    \n",
    "     name,value=line.strip().split('=',1)    \n",
    "     cookies[name]=value          #为字典cookies添加内容 \n",
    "r=requests.get(\"https://www.taobao.com\",cookies=cookies)  #cookies中的内容作为参数\n",
    "print(r.status_code)\n",
    "print(cookies)\n",
    "\n",
    "fb=open(\"C:\\\\Users\\\\Administrator\\\\Desktop\\\\爬虫\\\\淘宝.html\",\"wb\")\n",
    "fb.write(r.content)\n",
    "fb.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc3e3904-e044-4570-9491-e8441d681051",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12422f00-30b5-4b58-87df-0e558413ca92",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6399ed1d-f24b-4d15-9616-210f88e71a7d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
